//
// Created by vivi on 07/02/2018.
//

#pragma once

#include <cstdio>
#include <cstdlib>

/*
 * Safe Delete
 */
#define SafeDelete(item_) if(item_ != nullptr) delete item_
#define SafeDeleteArray(item_) if(item_ != nullptr) delete [] item_

/*
 * Some useful definitions for debugging so that we could access all the private data in the class
 * */
#if defined(NDEBUG) && !defined(HAIRENGINE_TEST)
	#define Public public
	#define Protected protected
	#define Private private
#else
	#define Public public
	#define Protected public
	#define Private public
#endif

/*
 * Error reporting in debug mode
 */
#define Printf(args...) ((void)printf(args))
#ifdef NDEBUG
	#define Info(args...) ((void)0)
#else
	#define Info(args...) ((void)printf(args))
#endif

#define Error(args...) {Info(args);assert(false);}

/*
 * An if expression for debugging
 */
#ifdef NDEBUG
#define ON_DEBUG 0
#else
#define ON_DEBUG 1
#define HAIRENGINE_DEBUG_ON
#endif

#define IF_ON_DEBUG if(ON_DEBUG)

/*
* Assertion
*/
#ifdef NDEBUG
#define Assert(expr_) ((void)0)
#else
#define Assert(expr_) if(!(expr_))Error("Assertion \"%s\" failed in \"%s\", line %d.", #expr_, __FILE__, __LINE__)
#endif
